package com.medvalley.tcm.controller.admin.controller;

import com.medvalley.tcm.base.Result;
import com.medvalley.tcm.cache.RedisCache;
import com.medvalley.tcm.controller.BaseController;
import com.medvalley.tcm.controller.admin.vo.inputvo.AdminSearchDoctorInputVo;
import com.medvalley.tcm.controller.admin.vo.outputvo.DoctorOutputVo;
import com.medvalley.tcm.controller.admin.vo.outputvo.PageDataOutputVo;
import com.medvalley.tcm.service.DoctorService;
import com.medvalley.tcm.vo.outputvo.DoctorPageOutputVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author linsong
 * @date 2019/5/7 14:16
 **/
@RestController("adminDoctorController")
@RequestMapping("/admin/doctor")
@Api("管理后台医生相关接口")
public class DoctorController extends BaseController {

    @Autowired
    private DoctorService doctorService;


    @ApiOperation("获取未审核医生列表")
    @RequestMapping(value = "/list_no_credential", method = RequestMethod.GET)
    public Result pageDoctor(@RequestParam int pageSize, @RequestParam int pageNo) {
        DoctorPageOutputVo doctorPageOutputVo = new DoctorPageOutputVo();
        doctorPageOutputVo.setPageNo(pageNo);
        doctorService.findNotCredentialDoctor(pageNo, pageSize, doctorPageOutputVo);
        return success(doctorPageOutputVo);
    }

    @ApiOperation("审核")
    @RequestMapping(value = "/check", method = RequestMethod.GET)
    public Result updateDoctorCredential(@RequestParam long id, @RequestParam int status) {
        doctorService.updateCredentialStatus(id, status);
        return success();
    }

    @ApiOperation("检索")
    @RequestMapping(value = "/search", method = RequestMethod.GET)
    public Result search(@ModelAttribute AdminSearchDoctorInputVo searchDoctorInputVo) {
        PageDataOutputVo<DoctorOutputVo> outputVo = doctorService.search(searchDoctorInputVo);
        return success(outputVo);
    }


    @ApiOperation("删除")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    public Result delete(@RequestParam long id) {
        doctorService.deleteDoctor(id);
        return success();
    }
}
